<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Sitepage
 * @copyright  Copyright 2010-2011 BigStep Technologies Pvt. Ltd.
 * @license    http://www.socialengineaddons.com/license/
 * @version    $Id: edit_tabs.tpl 2011-05-05 9:40:21Z SocialEngineAddOns $
 * @author     SocialEngineAddOns
 */
?>
<?php
	$this->headLink()
  ->appendStylesheet($this->seaddonsBaseUrl()
    . '/application/modules/Sitepage/externals/styles/style_sitepage_dashboard.css');

  $this->headScript()
					->appendFile($this->seaddonsBaseUrl() . '/application/modules/Sitepage/externals/scripts/core.js');
?>
<?php
	$this->headScript()
		->appendFile($this->seaddonsBaseUrl().'/externals/moolasso/Lasso.js')
		->appendFile($this->seaddonsBaseUrl().'/externals/moolasso/Lasso.Crop.js')
?>
<?php
$this->headScript()
        ->appendFile($this->seaddonsBaseUrl() . '/externals/autocompleter/Observer.js')
        ->appendFile($this->seaddonsBaseUrl() . '/externals/autocompleter/Autocompleter.js')
        ->appendFile($this->seaddonsBaseUrl() . '/externals/autocompleter/Autocompleter.Local.js')
        ->appendFile($this->seaddonsBaseUrl() . '/externals/autocompleter/Autocompleter.Request.js');
?>

<?php
	//GET SITEPAGE OBJECT
	$sitepage = Engine_Api::_()->getItem('sitepage_page', $this->page_id);

	//INITILIZING THE PRIVACY VARIABLES
  $editPrivacy = Engine_Api::_()->sitepage()->isManageAdmin($sitepage, 'edit');
  $overviewPrivacy = Engine_Api::_()->sitepage()->isManageAdmin($sitepage, 'overview');
  $mapPrivacy = Engine_Api::_()->sitepage()->isManageAdmin($sitepage, 'map');
  $insightPrivacy = Engine_Api::_()->sitepage()->isManageAdmin($sitepage, 'insight');
  $contactPrivacy = Engine_Api::_()->sitepage()->isManageAdmin($sitepage, 'contact');
  $profileTypePrivacy= Engine_Api::_()->sitepage()->isManageAdmin($sitepage, 'profile');
  $contactSpicifyFileds =  0;
	$offerPrivacy = 0;
	$formPrivacy = 0;
  $badgePrivacy=0;

	//OFFER PRIVACY
	$sitepageofferEnabled = Engine_Api::_()->getDbtable('modules', 'core')->isModuleEnabled('sitepageoffer');
  if($sitepageofferEnabled) {
		$offerPrivacy = Engine_Api::_()->sitepage()->isManageAdmin($sitepage, 'offer');
	}

	//FORM PRIVACY
	$sitepageFormEnabled = Engine_Api::_()->getDbtable('modules', 'core')->isModuleEnabled('sitepageform');
  if($sitepageFormEnabled) {
		$formPrivacy = Engine_Api::_()->sitepage()->isManageAdmin($sitepage, 'form');
	}

	//SPECIFIC CONTENT DETAILS FIELDS
	$pageOwner = Engine_Api::_()->user()->getUser($sitepage->owner_id);
	$view_options = (array) Engine_Api::_()->authorization()->getAdapter('levels')->getAllowed('sitepage_page', $pageOwner, 'contact_detail');
	$availableLabels = array('phone' => 'Phone', 'website' => 'Website', 'email' => 'Email',);
	$options_create = array_intersect_key($availableLabels, array_flip($view_options));
	if(!empty ($options_create)){
		$contactSpicifyFileds=1;
	}

  //BADGE PRIVACY
	$badgeCount = 0;
  $sitepageBadgeEnabled = Engine_Api::_()->getDbtable('modules', 'core')->isModuleEnabled('sitepagebadge');
	if(!empty($sitepageBadgeEnabled)) {
		$badgePrivacy = Engine_Api::_()->sitepage()->isManageAdmin($sitepage, 'badge');
		if(!empty ($badgePrivacy)){
			$badgeCount = Engine_Api::_()->sitepagebadge()->badgeCount();
		}
  }

	$wishlistCount = 0;
	$sitepagewishlistEnabled = Engine_Api::_()->getDbtable('modules', 'core')->isModuleEnabled('sitepagewishlist');
	if($sitepagewishlistEnabled) {
		$wishlistCount = Engine_Api::_()->sitepagewishlist()->wishlistCount($sitepage->page_id);
	}


?>
<div class="dashboard_left_column">
	<ul class="dashboard_tabs">
		  <?php if ($editPrivacy ):?>
      <li>
        <a class="<?php if($this->sitepages_view_menu == 12){ echo 'selected';} ?>" href="javascript:void(0);" onclick='ShowDashboardPageContent ("<?php echo $this->url(array('action' =>'get-started', 'page_id' => $this->page_id), 'sitepage_dashboard', true) ?>", 12)'; id="id_12"><?php echo $this->translate('Get Started'); ?></a>
      </li>
			<li>
				<a class="<?php if($this->sitepages_view_menu == 1){ echo 'selected';} ?>" href="javascript:void(0);" onclick='ShowDashboardPageContent ("<?php echo $this->url(array('page_id' => $this->page_id), 'sitepage_edit', true) ?>", 1)'; id="id_1" ><?php echo $this->translate('Edit Info'); ?></a>
			</li>
			<li>
				<a class="<?php if($this->sitepages_view_menu == 22){ echo 'selected';} ?>" href="javascript:void(0);" onclick='ShowDashboardPageContent ("<?php echo $this->url(array('action' => 'profile-picture', 'page_id' => $this->page_id), 'sitepage_dashboard', true) ?>", 22)'; id="id_22"><?php echo $this->translate('Profile Picture'); ?></a>
			</li>
      <?php if($overviewPrivacy): ?>
			<li >
				<a class="<?php if($this->sitepages_view_menu == 2){ echo 'selected';} ?>" href='<?php echo $this->url(array('action'=> 'overview', 'page_id' => $this->page_id), 'sitepage_dashboard', true) ?>' id="id_2" ><?php echo $this->translate('Overview'); ?></a>
			</li>
      <?php endif; ?>

      <?php if ($contactPrivacy && $contactSpicifyFileds ):?>
			<li>
				<a class="<?php if($this->sitepages_view_menu == 13){ echo 'selected';} ?>" href="javascript:void(0);" onclick='ShowDashboardPageContent ("<?php echo $this->url(array('action' => 'contact', 'page_id' => $this->page_id), 'sitepage_dashboard', true) ?>", 13)'; id="id_13"><?php echo $this->translate('Contact Details'); ?></a>
			</li>
      <?php endif; ?>
		  <?php if (Engine_Api::_()->sitepage()->enableLocation() && $mapPrivacy ): ?>
			<li>
					<a class="<?php if($this->sitepages_view_menu == 4){ echo 'selected';} ?>" href='<?php echo $this->url(array('action' => 'edit-location', 'page_id' => $this->page_id), 'sitepage_dashboard', true) ?>' id="id_4" ><?php echo $this->translate('Location'); ?></a>
			</li>
		  <?php endif; ?>
		  <?php if ($profileTypePrivacy):?>
			<li>
				<a class="<?php if($this->sitepages_view_menu == 10){ echo 'selected';} ?>" href='<?php echo $this->url(array('action' => 'profile-type', 'page_id' => $this->sitepage->page_id, 'profile_type' => $this->sitepage->profile_type),  'sitepage_dashboard',true) ?>' id="id_10" ><?php echo $this->translate('Profile Info'); ?></a>
			</li>
		  <?php endif; ?>
       <?php if(Engine_Api::_()->sitepage()->getEnabledSubModules()): ?>
				<li>
					<a class="<?php if($this->sitepages_view_menu == 16){ echo 'selected';} ?>" href="javascript:void(0);" onclick='ShowDashboardPageContent ("<?php echo $this->url(array('action' => 'app', 'page_id' => $this->sitepage->page_id),  'sitepage_dashboard',true) ?>", 16)'; id="id_16"><?php echo $this->translate('Apps'); ?></a>
				</li>
     <?php endif; ?>
      <li>
				<a class="<?php if($this->sitepages_view_menu == 20){ echo 'selected';} ?>" href="javascript:void(0);" onclick='ShowDashboardPageContent ("<?php echo $this->url(array('action'=> 'marketing', 'page_id' => $this->page_id), 'sitepage_dashboard', true) ?>", 20)'; id="id_20"><?php echo $this->translate('Marketing'); ?></a>
			</li>
      <?php $sitepagebadgeEnabled = Engine_Api::_()->getDbtable('modules', 'core')->isModuleEnabled('sitepagebadge'); ?>
			<?php if(!empty($sitepagebadgeEnabled) && $badgeCount): ?>
				<li >
					<a class="<?php if($this->sitepages_view_menu == 21){ echo 'selected';} ?>"  href="javascript:void(0);" onclick='ShowDashboardPageContent ("<?php echo $this->url(array('page_id' => $this->page_id), 'sitepagebadge_request', true) ?>", 21)'; id="id_21" ><?php echo $this->translate('Badge'); ?></a>
				</li>
			<?php endif; ?>
       <?php if($wishlistCount): ?>
			<li>
				<a class="<?php if($this->sitepages_view_menu == 35){ echo 'selected';} ?>" href="javascript:void(0);" onclick='ShowDashboardPageContent ("<?php echo $this->url(array('action' => 'dashboard-wishlist', 'page_id' => $this->sitepage->page_id),  'sitepagewishlist_general',true) ?>", 35)'; id="id_35"><?php echo $this->translate('Wishlist'); ?></a>
			</li>
		<?php endif; ?>
      <?php if ($insightPrivacy):?>
			<li>
			  <a class="<?php if($this->sitepages_view_menu == 8){ echo 'selected';} ?>" href='<?php echo $this->url(array('page_id' => $this->sitepage->page_id),  'sitepage_insights',true) ?>' id="id_8"><?php echo $this->translate('Insights'); ?></a>
		  </li>
			<li>
				<a class="<?php if($this->sitepages_view_menu == 23){ echo 'selected';} ?>" href='<?php echo $this->url(array('page_id' => $this->sitepage->page_id),  'sitepage_reports',true) ?>' id="id_23" ><?php echo $this->translate('Reports'); ?></a>
		  </li>
		 <?php endif; ?>
      <?php if (Engine_Api::_()->getApi('settings', 'core')->getSetting('sitepage.manageadmin', 1)):?>
			<li>
				 <a class="<?php if($this->sitepages_view_menu == 11){ echo 'selected';} ?>" href="javascript:void(0);" onclick='ShowDashboardPageContent ("<?php echo $this->url(array('action' => 'index', 'page_id' => $this->page_id), 'sitepage_manageadmins', true) ?>", 11)'; id="id_11"><?php echo $this->translate('Manage Admins'); ?></a>
			</li>
			<li >
				<a class="<?php if($this->sitepages_view_menu == 17){ echo 'selected';} ?>" href="javascript:void(0);" onclick='ShowDashboardPageContent ("<?php echo $this->url(array('action' => 'featured-owners', 'page_id' => $this->page_id), 'sitepage_dashboard', true) ?>", 17)'; id="id_17"><?php echo $this->translate('Featured Admins'); ?></a>
			</li>
		  <?php endif; ?>

      <?php if (Engine_Api::_()->sitepage()->allowStyle()):?>
       <li>
          <a class="<?php if($this->sitepages_view_menu == 3){ echo 'selected';} ?>" href="javascript:void(0);" onclick='ShowDashboardPageContent ("<?php echo $this->url(array('action' =>'edit-style', 'page_id' => $this->page_id), 'sitepage_dashboard', true) ?>", 3)'; id="id_3"><?php echo $this->translate('Edit Style'); ?></a>
       </li>
    <?php endif; ?>
    <?php if( Engine_Api::_()->getApi('settings', 'core')->sitepage_layoutcreate): ?>
			<li>
				<a href='<?php echo $this->url(array('page_id' => $this->page_id), 'sitepage_layout', true) ?>' ><?php echo $this->translate('Edit Layout'); ?></a>
			</li>
    <?php endif; ?>

     <?php if (Engine_Api::_()->sitepage()->hasPackageEnable() ):?>
       <li >
         <a class="<?php if($this->sitepages_view_menu == 15){ echo 'selected';} ?>" href="javascript:void(0);" onclick='ShowDashboardPageContent ("<?php echo $this->url(array('action' => 'update-package', 'page_id' => $this->page_id), 'sitepage_packages', true) ?>", 15)'; id="id_15"><?php echo $this->translate('Packages'); ?></a>
       </li>
     <?php endif; ?>
    <?php endif; ?>
	</ul>

  <div class="dashboard_info">
    <div class="dashboard_info_image">
			<?php echo $this->htmlLink(Engine_Api::_()->sitepage()->getHref($sitepage->page_id, $sitepage->owner_id ,$sitepage->getSlug()), $this->itemPhoto($sitepage, 'thumb.profile')) ?>
		</div>
		<center>
			<span>
			 	<?php if( $sitepage->declined==0 ): ?>
          <?php if ($sitepage->featured == 1): ?>
            <?php echo $this->htmlImage('application/modules/Sitepage/externals/images/sitepage_goldmedal1.gif', '', array('class' => 'icon', 'title' => $this->translate('Featured'))) ?>
          <?php endif; ?>
          <?php if ($sitepage->sponsored == 1): ?>
            <?php echo $this->htmlImage('application/modules/Sitepage/externals/images/sponsored.png', '', array('class' => 'icon', 'title' => $this->translate('Sponsored'))) ?>
          <?php endif; ?>
	        <?php if (empty($sitepage->approved) && empty ($sitepage->declined)): ?>
            <?php  $approvedtitle='Not approved';  if(empty($sitepage->aprrove_date)): $approvedtitle="Approval Pending"; endif; ?>
	        	<?php echo $this->htmlImage('application/modules/Sitepage/externals/images/sitepage_approved0.gif', '', array('class' => 'icon', 'title' => $this->translate($approvedtitle))) ?>
	        <?php endif; ?>
	        <?php if( $sitepage->closed ): ?>
	        	<?php echo $this->htmlImage('application/modules/Sitepage/externals/images/close.png', '', array('class' => 'icon', 'title' => $this->translate('Closed'))) ?>
	        <?php endif;?>
        <?php endif;?>
        <?php if( $sitepage->declined==1 ): ?>
					<?php echo $this->htmlImage('application/modules/Sitepage/externals/images/declined.gif', '', array('class' => 'icon', 'title' => $this->translate('Declined'))) ?>
				<?php endif;?>
			</span>
		</center>

    <?php if(Engine_Api::_()->sitepage()->hasPackageEnable()):?>
			<div>
				<b><?php echo $this->translate('Package: ') ?></b>
			     <a href='<?php echo $this->url(array("action"=>"detail" ,'id' => $sitepage->package_id), 'sitepage_packages', true) ?>' onclick="owner(this);return false;" title="<?php echo $this->translate(ucfirst($sitepage->getPackage()->title)) ?>"><?php echo $this->translate(ucfirst($sitepage->getPackage()->title)); ?></a>
      </div>
      <?php if(!$sitepage->getPackage()->isFree()):  ?>
        <div>
          <b><?php echo $this->translate('Payment: ')?></b>
          <?php if($sitepage->status=="initial"):
          	echo $this->translate("Not made");
          elseif($sitepage->status=="active"):
          	echo $this->translate("Yes");
          else:
          	echo $this->translate(ucfirst($sitepage->status));
          endif; ?>
      	</div>
    	<?php endif ?>
	  <?php endif ?>
		<div>
			<b><?php echo $this->translate('Status: ').Engine_Api::_()->sitepage()->getPageStatus($sitepage) ?></b>
		</div>
		<?php if(!empty($sitepage->aprrove_date)): ?>
			<div style="color: chocolate">
				<?php echo $this->translate('Approved '). $this->timestamp(strtotime($sitepage->aprrove_date)) ?>
			</div>
      <?php if(Engine_Api::_()->sitepage()->hasPackageEnable()):?>
        <div style="color: green;">
          <?php $expiry=Engine_Api::_()->sitepage()->getExpiryDate($sitepage);
          if($expiry !=="Expired" && $expiry !== $this->translate('Never Expires'))
            echo $this->translate("Expiration Date: ");
          	echo $expiry;
          ?>
        </div>
      <?php endif;?>
    <?php endif ?>


    <?php if (Engine_Api::_()->sitepage()->canShowPaymentLink($sitepage->page_id)): ?>
      <div class="tip center mtop5">
        <span class="db_payment_link">
          <a href='javascript:void(0);' onclick="submitSession(<?php echo $sitepage->page_id ?>)"><?php echo $this->translate('Make Payment'); ?></a>
          <form name="setSession_form" method="post" id="setSession_form" action="<?php echo $this->url(array(), 'sitepage_session_payment', true) ?>">
           <input type="hidden" name="page_id_session" id="page_id_session" />
          </form>
        </span>
      </div>
    <?php endif; ?>
    <?php if (Engine_Api::_()->sitepage()->canShowRenewLink($sitepage->page_id)): ?>
      <div class="tip mtop5">
        <span style="margin:0px;"> <?php echo $this->translate("Please click ");?>
          <a href='javascript:void(0);' onclick="submitSession(<?php echo $sitepage->page_id ?>)"><?php echo $this->translate('here'); ?></a><?php echo $this->translate(' to renew page.'); ?>
          <form name="setSession_form" method="post" id="setSession_form" action="<?php echo $this->url(array(), 'sitepage_session_payment', true) ?>">
           <input type="hidden" name="page_id_session" id="page_id_session" />
          </form>
        </span>
      </div>
    <?php endif; ?>
  </div>
</div>
 <?php if (Engine_Api::_()->sitepage()->canShowPaymentLink($sitepage->page_id)): ?>
    <div class="sitepage_edit_content">
      <div class="tip">
        <span>
          <?php echo $this->translate('The package for your Page requires payment. You have not fulfilled the payment for this Page.'); ?>
          <a href='javascript:void(0);' onclick="submitSession(<?php echo $sitepage->page_id ?>)"><?php echo $this->translate('Make payment now!'); ?></a>
          <form name="setSession_form" method="post" id="setSession_form" action="<?php echo $this->url(array(), 'sitepage_session_payment', true) ?>">
           <input type="hidden" name="page_id_session" id="page_id_session" />
          </form>
        </span>
      </div>
    </div>
    <?php endif; ?>
    <?php if (Engine_Api::_()->sitepage()->canShowRenewLink($sitepage->page_id)): ?>
      <div class="sitepage_edit_content">
      <div class="tip">
        <span>
         <?php if( $sitepage->expiration_date <= date('Y-m-d H:i:s')): ?>
          <?php echo "Your package for this Page has expired and needs to be renewed."?>
          <?php else:?>
          <?php echo "Your package for this Page is about to expire and needs to be renewed."?>
         <?php endif; ?>
           <?php echo $this->translate(" Click ");?>
          <a href='javascript:void(0);' onclick="submitSession(<?php echo $sitepage->page_id ?>)"><?php echo $this->translate('here'); ?></a><?php echo $this->translate(' to renew it.'); ?>
          <form name="setSession_form" method="post" id="setSession_form" action="<?php echo $this->url(array(), 'sitepage_session_payment', true) ?>">
           <input type="hidden" name="page_id_session" id="page_id_session" />
          </form>
        </span>
      </div>
      </div>
    <?php endif; ?>

<script type="text/javascript">
  var Show_Tab_Selected = "<?php echo $this->sitepages_view_menu;?>";
  function submitSession(id){
    document.getElementById("page_id_session").value=id;
    document.getElementById("setSession_form").submit();
  }

  function owner(thisobj) {
    var Obj_Url = thisobj.href;
    Smoothbox.open(Obj_Url);
  }
</script>